#include <string.h>
#include <assert.h>
#include <math.h>
#include <iomanip>
#include <iostream>;
using namespace std;

struct Point {
	float x, y;

	Point() {}

	Point(float x, float y) {
		this->x = x;
		this->y = y;
	}
};

struct Rectangle {
	Point* low, * high;

	Rectangle() {}

	Rectangle(float x, float y) {
		low = new Point(x, y);
		high = new Point(x, y);
	}

	Rectangle(float x1, float y1, float x2, float y2) {
		float minX = x1 < x2 ? x1 : x2;
		float minY = y1 < y2 ? y1 : y2;
		float maxX = x1 > x2 ? x1 : x2;
		float maxY = y1 > y2 ? y1 : y2;
		low = new Point(minX, minY);
		high = new Point(maxX, maxY);
	}

	void getBoundingRect(float x, float y) {
		low->x = low->x < x ? low->x : x;
		low->y = low->y < y ? low->y : y;
		high->x = high->x > x ? high->x : x;
		high->y = high->y > y ? high->y : y;
	}

	bool isContain(Rectangle* rect) {
		if (rect->low->x >= low->x && rect->high->x <= high->x) {
			if (rect->low->y >= low->y && rect->high->y <= high->y) {
				return true;
			}
		}
		return false;
	}

	bool isIntersection(Rectangle* rect) {
		if (low->x > rect->high->x || high->x < rect->low->x)
			return false;
		if (low->y > rect->high->y || high->y < rect->low->x)
			return false;
		return true;
	}

	bool isInner(float x, float y) {
		if (x < low->x || x > high->x)
			return false;
		if (y < low->y || y > high->y)
			return false;
		return true;
	}


	Point* getCenter() {
		return new Point((low->x + high->x) / 2, (low->y + high->y) / 2);
	}

	void toString() {
		cout << fixed << setprecision(2) << "low.x = " << low->x << " low.y = " << low->y << " high .x = " << high->x << " high.y = " << high->y << endl;
	}

};
